<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div {
            width: 100px;
            height: 100px;
            border: 1px solid #000;
        }
    </style>
    <script src="../jquery-1.12.4.js"></script>
    <script>
        // 原生js修改DOM背景颜色
        // window.onload = function () {
        //     var div1 = document.getElementsByTagName('div')[0];
        //     var div2 = document.getElementsByClassName('demo1')[0];
        //     var div3 = document.getElementById('demo2');
        //     div1.style.backgroundColor = 'red';
        //     div2.style.backgroundColor = 'pink';
        //     div3.style.backgroundColor = 'blue';
        // }
        // jQuery修改DOM背景颜色
        $(document).ready(function () {
            $('div').css('background', 'red');
            $('.demo1').css('background', 'pink');
            $('#demo2').css('background', 'blue');
        })
    </script>
</head>

<body>
    <div></div>
    <div class="demo1"></div>
    <div id="demo2"></div>
</body>

</html>